package tests;

import java.net.Socket;
import java.util.Iterator;

import poker.Client;
import poker.KaartSpel;
import poker.KaartStapel;
import poker.Server;
import poker.ServerConnection;
import poker.Spel;
import poker.Speler;

public class ServerTest {
	public static void main(String[] args){
		KaartStapel stapel = new KaartStapel();
		stapel.voegToe(new KaartSpel("Standaard"));
		System.out.println(stapel);
		
		Spel spel = new Spel(stapel);
		
		Server server = new Server(spel, 41114);
		
		server.start();

		Client c = new Client(new Speler("henk"), "localhost",41114);
		c.start();
		Client d = new Client(new Speler("piet"), "localhost",41114);
		d.start();
		
		try {
			Thread.sleep(2500);
			Iterator<ServerConnection> i = server.getClients().iterator();
			while(i.hasNext()){
				System.out.println(i.next());
			}
			server.startGame();
			
			Thread.sleep(1500);
			
			System.out.println("schop c en d");
			c.interrupt();
			d.interrupt();
			
			Thread.sleep(1000);
			System.out.println("Fold speler: "+c.speler);
			System.out.println("In spel: "+c.spel);
			c.spel.sr.fold(c.speler);
			
			
			
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
